package com.tengju.support.infrastructure.persistence.mybatis.mapper.tengju.custom;

import com.tengju.support.infrastructure.persistence.mybatis.dataobject.AppMessageCentreDetailDO;
import com.tengju.support.infrastructure.persistence.mybatis.dataobject.AppMessageCentreUnreadCountDO;
import com.tengju.support.infrastructure.persistence.mybatis.dataobject.SupportMessageDO;
import com.tengju.support.infrastructure.persistence.mybatis.dataobject.SupportMessageContentDO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface SupportMessageMapper {

    /**
     * 获取所有未读消息的数量
     */
    Long getAllUnreadTotal(@Param("userId") Long userId,
                           @Param("messageTypeList") List<Integer> messageTypeList,
                           @Param("readStatus") Integer readStatus,
                           @Param("sendStatus") Integer sendStatus);

    /**
     * 获取对应消息类型未读消息数量
     */
    List<AppMessageCentreUnreadCountDO> getMessageTypeUnreadTotal(@Param("userId") Long userId,
                                                                  @Param("readStatus") Integer readStatus,
                                                                  @Param("sendStatus") Integer sendStatus);

    /**
     * 消息中心-首页
     */
    AppMessageCentreDetailDO getMyMessageTypeDetail(@Param("userId") Long userId,
                                                    @Param("messageType") Integer messageType,
                                                    @Param("sendStatus") Integer sendStatus);

    /***
     * 消息中心-列表页
     */
    List<SupportMessageDO> queryMyMessageByPage(@Param("userId") Long userId,
                                                       @Param("messageType") Integer messageType,
                                                       @Param("sendStatus") Integer sendStatus,
                                                       @Param("offset") int offset,
                                                       @Param("limit") int limit);

    /**
     * 消息中心-列表页消息数量
     */
    Integer getMyMessageListTotal(@Param("userId") Long userId,
                                  @Param("messageType") Integer messageType,
                                  @Param("sendStatus") Integer sendStatus);


    void batchInsert(@Param("messageBatchRelations") List<SupportMessageDO> messageBatchRelations);

    Integer batchUpdateSendStatusByBatchId(@Param("batchId") String batchId,@Param("sendStatus") Integer sendStatus);

    Integer updateSendStatusByUserIdMessageId(@Param("userId") Long userId,@Param("taskId") Long taskId, @Param("sendStatus") Integer sendStatus);

    List<SupportMessageDO> queryUnSendRecordByMessageId(@Param("taskId") Long taskId, @Param("sendStatus") Integer sendStatus);



    /**
     * 消息未读更新未已读状态
     */
    void updateReadStatus(@Param("userId") Long userId,
                          @Param("messageType") Integer messageType,
                          @Param("readStatus") Integer readStatus,
                          @Param("sendStatus") Integer sendStatus);


    int countBySendStatusAndMessageId(@Param("sendStatus") List<Integer> sendStatus, @Param("taskId") Long taskId);
}
